<template>
    <div>
        <el-menu
                style="width: 200px; min-height: calc(100vh - 50px)"
                active-text-color="#ffd04b"
                background-color="#545c64"
                class="el-menu-vertical-demo"
                :default-active="path"
                text-color="#fff"
                :default-openeds="['1']"

                router

        >
            <!--@open="handleOpen"-->
            <!--@close="handleClose"-->
            <!--一级菜单-->

            <!--
                el-sub-menu ：定义子集菜单
                <template #title>：本菜单模板
                el-menu-item：无子集菜单
                el-menu-item-group：分组
            -->
            <!--<el-menu-item-group title="Group Two">-->
            <el-menu-item index="/">首页</el-menu-item>
            <el-sub-menu index="1">
                <template #title>
                    <el-icon><location /></el-icon>
                    <span>系统管理</span>
                </template>
                    <!--<el-menu-item index="user" @click="$router.push('/home')" > 用户管理</el-menu-item>-->

                    <el-menu-item index="/setting/user" v-if="user.role === 1"> 用户管理</el-menu-item>
                    <el-menu-item index="/setting/book">书籍管理</el-menu-item>
                    <el-menu-item index="/setting/person">个人管理</el-menu-item>
                    <el-menu-item index="/setting/news">新闻管理</el-menu-item>
                    <el-menu-item index="/setting/map">百度地图</el-menu-item>
                    <el-menu-item index="/setting/category">分类管理</el-menu-item>
                    <el-menu-item index="/setting/im">聊天室</el-menu-item>
                    <el-menu-item index="/setting/message">在线留言</el-menu-item>
                    <el-menu-item index="/setting/donate">请作者喝杯咖啡</el-menu-item>
                    <el-menu-item index="/setting/order">我的订单</el-menu-item>
                    <!--定义二级菜单-->
                    <el-sub-menu index="1-3">
                        <template #title> item four  </template>
                        <!--三级菜单-->
                        <el-menu-item index="1-3-1">item one</el-menu-item>
                    </el-sub-menu>

            </el-sub-menu>


            <!--                        禁用-->
            <el-menu-item index="2" disabled>
                <el-icon><document /></el-icon>
                <span>Navigator Three</span>
            </el-menu-item>


        </el-menu>
    </div>
</template>
<!--<script setup>-->
<!--    import {Edit} from '@element-plus/icons'-->
<!--</script>-->
<script>

    //main.ts文件
    //main.ts文件
    import {Setting} from '@element-plus/icons'
    import request from "../utils/request";
    export default {
        name: "Aside",
        components: {
            Setting
        },
        data() {
            return {
                //高亮
                path: this.$route.path
            }
        },

        created() {
            let userStr = sessionStorage.getItem("user") || "{}"
            this.user = JSON.parse(userStr)

            // // 请求服务端，确认当前登录用户的 合法信息
            request.get("/user/" + this.user.id).then(res => {
              if (res.code === '0') {
                this.user = res.data
              }
            })
        }
    }






</script>

<style scoped>

</style>
